package main

func Defer() {
	//定义两个匿名函数
	defer func() {
		println("这是第一个defer")
	}()

	defer func() {
		println("这是第二个defer")
	}()
}

func DeferClosure() {
	i := 0
	defer func() {
		println(i)

	}()
	i = 1
}
func DeferClosure1() {
	i := 0
	defer func(val int) {
		println(val)

	}(i)
	i = 1
}
func DeferClosure2() (a int) {
	a = 0
	defer func() {
		a = 1
	}()
	return a
}
